package cc.ilzy.mall.coupon.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    @Value("classpath:redisson.yaml")
    private org.springframework.core.io.Resource configFile;

    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() throws Exception {
        // 从外部文件加载配置
        Config config = Config.fromYAML(configFile.getInputStream());
        return Redisson.create(config);
    }
}
